import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { NoticeForm, NoticePage, NoticeQuery } from "./types";

/**
 * 获取分页列表
 *
 * @param queryParams
 */
export function getNoticePage(
  queryParams: NoticeQuery
): AxiosPromise<PageResult<NoticePage[]>> {
  return request({
    url: "/admin/notice/index",
    method: "get",
    params: queryParams,
  });
}

export function getNoticeLst(): AxiosPromise<NoticePage[]> {
  return request({
    url: "/admin/notice/getLst",
    method: "get",
  });
}

/**
 * 获取表单详情
 *
 * @param ids
 */
export function getNoticeForm(ids: string): AxiosPromise<NoticeForm> {
  return request({
    url: "/admin/notice/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}

/**
 * 添加
 *
 * @param data
 */
export function addNotice(data: any) {
  return request({
    url: "/admin/notice/add",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function updateNotice(data: NoticeForm) {
  return request({
    url: "/admin/notice/edit",
    method: "put",
    data: data,
  });
}

/**
 * 删除
 *
 * @param data
 */
export function deleteNotice(data: any) {
  return request({
    url: "/admin/notice/del",
    method: "delete",
    data,
  });
}
